<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\KefuController;
use App\Http\Controllers\Api\WorkttwkController;
use App\Http\Controllers\Api\UploadController;
use App\Http\Controllers\Api\HtmlossController;
use App\Http\Controllers\Api\WechatController;
use App\Http\Controllers\Api\LinksthirdController;
use App\Http\Controllers\Api\UsersController;
use App\Http\Controllers\Api\LinkslistsController;
use App\Http\Controllers\Api\LinksapiController;
use App\Http\Controllers\Api\IndexController;
use App\Http\Controllers\Api\LinksController;
use App\Http\Controllers\Api\OrdersController;
use App\Http\Controllers\Api\LinksstaticController;
use App\Http\Controllers\Api\StatisticsController;
use App\Http\Controllers\Api\OffiaccountController;
use App\Http\Controllers\Api\LoginController;
use App\Http\Controllers\Home\GoodsController;
use App\Http\Controllers\Home\WebController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::any('wechat_notify',[GoodsController::class, 'wechatNotify']); // 微信回调

Route::group(['prefix' => 'version/{vid}'], function () {
    Route::get('send_msn',[UsersController::class,'sendMsn']);  // 发送短信
    Route::group(['prefix' => 'login'], function() {
        Route::post('get_login_token',[IndexController::class,'getLoginToken']); //获取登录token
    });

    Route::group(['prefix' => 'alipay'], function () {
        Route::post('alipayCallBack',[UsersController::class,'alipayCallBack']);                                    // 支付宝支付异步回掉
    });
    Route::group(['prefix' => 'wechat'], function () {
        Route::any('scan_pay',[IndexController::class,'scanPay']); // 微信扫码支付回掉
        Route::any('wechat_back',[IndexController::class,'wechatPayBack']); // 微信扫码支付回掉
    });

    Route::group(['prefix' => 'orders', "middleware" => ['apiauth']], function () {
        Route::get('user_orders',[OrdersController::class,'userOrders']);                                           // 用户订单列表
        Route::get('agent_orders',[OrdersController::class,'agentOrders']);                                         // 代理订单列表
        Route::get('agent_price',[OrdersController::class,'agentPrice']);                                           // 代理修改订单金额
        Route::get('orders_repay',[OrdersController::class,'ordersRepay']);                                         // 订单重新支付
    });

    Route::group(['prefix' => 'offiaccount'], function () {
        Route::any('event_msg',[OffiaccountController::class,'listenMsg']);
        Route::any('menu_set',[OffiaccountController::class,'setOffiaccountMenu']);
        Route::any('meida_lists',[OffiaccountController::class,'getOffiaccountMeida']);
        Route::get('wechat_jssdk',[OffiaccountController::class,'wechatJssdk']);
    });

    Route::group(['prefix' => 'upload'], function () {
        Route::get('upload_access_token',[UploadController::class,'getAccessToken']);
        Route::any('alioss_upload_back',[UploadController::class,'aliossUploadBack']);
        Route::post('base_upload',[UploadController::class,'base64Upload'])->middleware('apiauth');
        Route::post('upload_miniapp_media',[WechatController::class,'uploadMiniappMedia'])->middleware('apiauth');
    });

    Route::group(['prefix' => 'open'], function () {
        Route::any('authorization_notice',[WechatController::class,'authorizationNotice']);
        Route::any('event_reception/{appid}/event_back',[WechatController::class,'eventReceptionBack']);
        Route::any('mini_authorization_notice',[WechatController::class,'miniAuthorizationNotice']);
        Route::any('event_reception/{appid}/mini_event_back',[WechatController::class,'miniEventReceptionBack']);
    });

    Route::group(['prefix' => 'oss'], function () {
        Route::post('empty_generate',[HtmlossController::class,'emptyOssGenerate']);
        Route::get('alioss_access_token',[UploadController::class,'getAccessToken']);
        Route::any('alioss_upload_back',[UploadController::class,'aliossUploadBack']);
    });

    Route::group(['prefix' => 'login'], function () {
        Route::get('home_login',[LoginController::class,'homeLogin']);
    });
});

Route::get('/slb_check', function (Request $request) {
    return "success";
});

Route::get('/offiaccount/get_qrcode',[WebController::class,'loginQrcode']);